<template>
	<!-- 可用回收券 -->
	<view>
		<!-- #ifdef APP-PLUS -->
		<view class="status_bar"></view>  
		<!-- #endif -->
		<navbar title="可用回收券"/>
		<view class="coupon_list" v-for="(coupon,i) in recycleCouponList" :key="i">
			<view class="coupon_item">
				<view class="coupon_price">{{coupon.recycle_ratio}}%</view>
				<view class="coupon_info">
					<view class="coupon_title">{{coupon.coupon_name}}</view>
					<view class="coupon_name">{{coupon.activity_name}}</view>
					<view class="coupon_limittime">有效期至 {{coupon.end_tme}}</view>
				</view>
				<view class="line"></view>
				<view class="coupon_status" @click="selectCoupon(coupon)">
					<text>去使用</text>
				</view>
			</view>
		</view>
		<!-- 加载更多 -->
		<pullDownRefresh :status="loading" />
	</view>
</template>

<script>
	import pullDownRefresh from '@/components/pullDownRefresh'
	export default {
		components:{
			pullDownRefresh
		},
		data() {
			return {
				recycleCouponList:[],//回收券列表
				loading:0,
				activity_id:0
			}
		},
		onLoad(opt) {
			console.log(opt);
			this.activity_id = opt.activity_id;
			this.getCouponList();
		},
		methods: {
			//获取回收券列表
			getCouponList(){
				this.page = 1;
				this.$api.backpackcouponlis({
					activity_id:this.activity_id
				}).then(res=>{
					this.recycleCouponList = res;
				})
			},
			//选择回收券
			selectCoupon(opt){
				let page = getCurrentPages();
				let prevPage = page[page.length-2];
				prevPage.$vm.coupon = opt;
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss">
page{
	padding-top: calc(var(--status-bar-height) + 100rpx);
}
.coupon_list{
	
	.coupon_item{
		width: 690rpx;
		height: 200rpx;
		background: linear-gradient(223deg, #01E9FF 0%, #985FFF 100%);
		border-radius: 20rpx;
		margin: 30rpx;
		position: relative;
		display: flex;
		align-items: center;
		
		.coupon_price{
			font-size: 72rpx;
			font-family: Source Han Sans CN;
			font-weight: bold;
			color: #FFFFFF;
			width: 310rpx;
			text-align: center;
		}
		.coupon_info{
			width: 333rpx;
			margin-right: 10rpx;
			
			.coupon_title{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #FFFFFF;
				@include one;
			}
			.coupon_name{
				font-size: 28rpx;
				font-family: Source Han Sans CN;
				font-weight: bold;
				color: #FFFFFF;
				@include one;
				transform: translateY(30rpx);
			}
			.coupon_limittime{
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				font-weight: 400;
				color: #FFFFFF;
				@include one;
				margin-top: 63rpx;
			}
		}
	}
	.line{
		width: 1rpx;
		height: 170rpx;
		border: 1rpx dashed #FFFFFF;
		position: relative;
		
		&::before{
			content: '';
			width: 30rpx;
			height: 30rpx;
			border-radius: 50%;
			background-color: $page;
			position: absolute;
			top: -35rpx;
			left: 50%;
			transform: translateX(-50%);
		}
		&::after{
			content: '';
			width: 30rpx;
			height: 30rpx;
			border-radius: 50%;
			background-color: $page;
			position: absolute;
			bottom: -35rpx;
			left: 50%;
			transform: translateX(-50%);
		}
	}
	.coupon_status{
		width: 189rpx;
		@include center;
		
		text{
			font-size: 24rpx;
			font-family: Source Han Sans CN;
			font-weight: 400;
			color: #FFFFFF;
		}
	}
}
</style>
